package ylsb.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ylsb.service.Hc45Service;
import ylsb.service.ShijiService;
import ylsb.service.YiyonghaocaiService;
import ylsb.support.JsonResult;
import ylsb.support.PageInfo;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("hc45")
public class Hc45Controller {

    @Resource
    private Hc45Service ddService;

    public Logger log = LoggerFactory.getLogger(YltpBaofeiController.class);

    @RequestMapping("findhc45list")
    public JsonResult<?> findhc45list(@RequestParam("xiangmuid") String ppxiangmuId, @RequestParam("pageindex") int ppPageIndex,
                                       @RequestParam("pagesize") int ppPageSize) {

        return ddService.findhc45list(ppxiangmuId, ppPageIndex, ppPageSize);
    }

    @RequestMapping("findBiaojuelist")
    public JsonResult<?> findBiaojuelist(@RequestParam("xiangmuid") String ppxiangmuId, @RequestParam("userid") String userid,
//                                         @RequestParam("tiaojian") String pptiaojian,
                                         @RequestParam("pageindex") int ppPageIndex, @RequestParam("pagesize") int ppPageSize) {

        return ddService.findBiaojuelist(ppxiangmuId, userid, ppPageIndex, ppPageSize);
    }
    @RequestMapping("delete")
    public JsonResult<?> delete(@RequestParam("xiangmuid") String ppxiangmuId){
        try {

            return ddService.deleteByxiangmuId(ppxiangmuId)==true? JsonResult.getSuccessResult("删除材料成功")
                    : JsonResult.getErrorResult("删除材料失败");

        }catch (Exception e) {
            e.printStackTrace();
            log.error("hc34/delete:error",e);
            return JsonResult.getErrorResult("hc45/delete:error " + e.getMessage());
        }
    }
}
